import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from "@/layout/index.vue";


Vue.use(VueRouter)

export const constantRoutes = [
  {
    path: '/admin/login',
    name: 'adminLogin',
    hidden: true,
    component: () => import("@/views/admin/login.vue"),
  },
  {
    path: '/admin',
    component: Layout,
    redirect: '/admin/index',
    children: [
      {
        path: '/admin/index',
        component: () => import('@/views/admin/Index.vue'),
        name: 'Index',
        meta: {
          title: '首页',
          icon: 'dashboard',
          affix: true
        },
      },
    ]
  },
  {
    path: '/frontEnd/user/homePage',
    component: () => import("@/views/frontEnd/UserHomePage"),
    children: [
      {
        path: '/frontEnd/PersonalCommentsList',
        component: () => import("@/views/frontEnd/PersonalCommentsList"),
      },
      {
        path: '/frontEnd/space',
        component: () => import("@/views/frontEnd/SpaceView"),
      },
      {
        path: '/frontEnd/userdata',
        component: () => import("@/views/frontEnd/UserData"),
      },
    ]
  },
  {
    path: '/frontEnd/homePage',
    component: () => import("@/views/frontEnd/HomePage"),
  },

  {
    path: '/frontEnd/articleDetail',
    component: () => import("@/views/frontEnd/ArticleDetail"),
  },
  {
    path: '/frontEnd/userLogin',
    component: () => import("@/views/frontEnd/UserLogin"),
  },
  {
    path: '/frontEnd/userReg',
    component: () => import("@/views/frontEnd/UserReg"),
  },
  {
    path: '/frontEnd/postArticle',
    component: () => import("@/views/frontEnd/postArticle"),
  }
]

const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function (location) {
  return routerPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: constantRoutes
})

export default router
